﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model;

namespace com.lover.astd.common.logicexe.economy
{
    public class DinnerExe : ExeBase
    {
        public DinnerExe() { _name = ConfigStrings.S_Dinner; _readable = ConfigStrings.SR_Dinner; }
        public override long execute()
        {
            if (_user.Level < 80) return next_day();
            Dictionary<string, string> confs = getConfig();
            if (!confs.ContainsKey(ConfigStrings.enabled) || !confs[ConfigStrings.enabled].ToLower().Equals("true")) return next_day();
            MiscMgr mgr = ServiceFactory.getMiscManager();
            _user._dinner_joined = false;
            mgr.getDinnerInfo(_proto, _logger, _user);
            if (_user._dinner_count == 0) return next_dinner();
            if (_user._dinner_in_time == 0) return next_dinner();
            if (_user._dinner_team_id == "" || _user._dinner_joined) return 30 * 1000;
            logInfo(String.Format("发现宴会, [{0}][{1}]", _user._dinner_team_creator, _user._dinner_team_id));
            mgr.joinDinner(_proto, _logger, _user);
            return immediate();
        }
    }
}
